import  Vue from 'vue'
import Cookie from  'js-cookie'
export default function ({ $axios, redirect}) {
  let  token=Cookie.get('token')
  $axios.onRequest(config => {
    console.log('Making request to ' + config.url)
    console.log(token)
    if (token){
      config.headers['Authorization']='bearer '+token
    }
  })

  $axios.onError(error => {

    console.log(error);
    const code = parseInt(error.response && error.response.status)
    if (code ==500 ) {

   }
  })
  $axios.onResponseError(error=>{
    console.log(Vue)
    Vue.$Message.error('服务器错误')

  })
}
